#! /bin/bash
NOW_DIR=$(cd -P $(dirname $0);pwd)
WWW_DIR=$(dirname $NOW_DIR)
DOCKER_DIR=$WWW_DIR/docker

chmod -R 777 ${WWW_DIR}

#站点目录
au_callie_com=${DOCKER_DIR}/dev.au.callie.com
ca_callie_com=${DOCKER_DIR}/dev.ca.callie.com
fr_callie_com=${DOCKER_DIR}/dev.fr.callie.com
uk_callie_com=${DOCKER_DIR}/dev.uk.callie.com
www_callie_com=${DOCKER_DIR}/dev.www.callie.com
www_callie_de=${DOCKER_DIR}/dev.www.callie.de

#sql文件
echo "开始拷贝初始化sql文件"
sql_file=${DOCKER_DIR}/callie_local2.sql
mkdir -p ${au_callie_com}/files/mysql5.7.18/sql
mkdir -p ${ca_callie_com}/files/mysql5.7.18/sql
mkdir -p ${fr_callie_com}/files/mysql5.7.18/sql
mkdir -p ${uk_callie_com}/files/mysql5.7.18/sql
mkdir -p ${www_callie_com}/files/mysql5.7.18/sql
mkdir -p ${www_callie_de}/files/mysql5.7.18/sql
#cp -ar ${sql_file} ${au_callie_com}/files/mysql5.7.18/sql/callie_local2.sql
#cp -ar ${sql_file} ${ca_callie_com}/files/mysql5.7.18/sql/callie_local2.sql
#cp -ar ${sql_file} ${fr_callie_com}/files/mysql5.7.18/sql/callie_local2.sql
#cp -ar ${sql_file} ${uk_callie_com}/files/mysql5.7.18/sql/callie_local2.sql
#cp -ar ${sql_file} ${www_callie_com}/files/mysql5.7.18/sql/callie_local2.sql
#cp -ar ${sql_file} ${www_callie_de}/files/mysql5.7.18/sql/callie_local2.sql

chmod -R 777 ${DOCKER_DIR}
#授权files文件夹只读
echo "开始授权files文件夹只读"
chmod -R 644 ${au_callie_com}/files
chmod -R 644 ${ca_callie_com}/files
chmod -R 644 ${fr_callie_com}/files
chmod -R 644 ${uk_callie_com}/files
chmod -R 644 ${www_callie_com}/files
chmod -R 644 ${www_callie_de}/files

echo "开始启动6个站点"
cd ${au_callie_com} && docker-compose up -d
cd ${ca_callie_com} && docker-compose up -d
cd ${fr_callie_com} && docker-compose up -d
cd ${uk_callie_com} && docker-compose up -d
cd ${www_callie_com} && docker-compose up -d
cd ${www_callie_de} && docker-compose up -d

echo '启动6个站点成功！！！'
